package com.test;

import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;
/*
* ShapePanel.java
*/
public class ShapePanel extends JPanel {
public ShapePanel(){
setBackground(Color.white);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLUE);
//g.drawLine(0,10,50,60);
//g.setColor(Color.red);
g.setColor(Color.GREEN);
g.drawRect(50,10,150,65);
g.setColor(new Color(255,0,0));

g.drawRect(200,35,40,40);
g.setColor(new Color(255,0,0));

g.fillOval(75,50,50,50);
g.setColor(new Color(0,255,0));

g.fillOval(175,50,50,50);
g.setColor(new Color(0,255,0));

//g.fillOval(180,50,50,50);
//g.setColor(new Color(0,255,0));

//g.fillArc(150,10,50,50,0,180);
Graphics2D g2 =(Graphics2D)g;
// fill RoundRectangle2D.Double
GradientPaint redtowhite = new GradientPaint(200,10,Color.red,250, 10,Color.black);
g2.setPaint(redtowhite);
g2.fill(new RoundRectangle2D.Double(55, 15, 25,25, 10, 10));

//Graphics2D g2 =(Graphics2D)g;
// fill RoundRectangle2D.Double
GradientPaint redtowhite1 = new GradientPaint(200,10,Color.red,250, 10,Color.black);
g2.setPaint(redtowhite1);
g2.fill(new RoundRectangle2D.Double(85, 15, 25,25, 10, 10));

GradientPaint redtowhite2 = new GradientPaint(200,10,Color.red,250, 10,Color.black);
g2.setPaint(redtowhite2);
g2.fill(new RoundRectangle2D.Double(115, 15, 25,25, 10, 10));

GradientPaint redtowhite3 = new GradientPaint(200,10,Color.red,250, 10,Color.black);
g2.setPaint(redtowhite3);
g2.fill(new RoundRectangle2D.Double(145, 15, 25,25, 10, 10));

GradientPaint redtowhite4 = new GradientPaint(200,10,Color.red,250, 10,Color.black);
g2.setPaint(redtowhite4);
g2.fill(new RoundRectangle2D.Double(175, 15, 23,45, 10, 10));
//g2.setPaint();
//g2.drawString("Filled RoundRectangle2D", 200, 80);
}
public static void main(String args[]){
JFrame frame = new JFrame( "Grafik 2 Dimensi" );
frame.addWindowListener( new WindowAdapter(){
    @Override
    public void windowClosing( WindowEvent e ){
System.exit( 0 );
}
});
frame.setLayout(new BorderLayout());
ShapePanel shapePanel = new ShapePanel();
frame.add(shapePanel,BorderLayout.CENTER);
frame.setSize( 450, 250 );
frame.setVisible(true);
}
}